<template>
  <div class="container-box">
    <div class="app-container role-container">
      <el-form :inline="true" class="sys-el-form">
        <el-form-item label="部门名称">
          <el-input
            v-model="queryParams.deptName"
            placeholder="请输入部门名称"
            clearable
            prefix-icon="el-icon-search"
            size="small"
            style="width:180px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="queryParams.status" placeholder="部门状态" clearable size="small">
            <el-option
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            class="filter-item"
            icon="el-icon-search"
            type="primary"
            size="mini"
            @click="handleQuery"
          >搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="handRefresh">刷新</el-button>
          <el-button
            class="filter-item"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['system:dept:add']"
          >新增</el-button>
          <el-button
            class="filter-item"
            icon="el-icon-plus"
            size="mini"
            @click="projectAdd"
            v-hasPermi="['system:dept:addeng']"
          >新增工程商</el-button>
          <el-button
            class="filter-item"
            icon="el-icon-plus"
            size="mini"
            @click="propertyAdd"
            v-hasPermi="['system:dept:property']"
          >新增物业</el-button>
          <el-button
            class="filter-item"
            icon="el-icon-plus"
            size="mini"
            @click="communityAdd"
            v-hasPermi="['system:dept:community']"
          >新增小区</el-button>
          <el-button
            class="filter-item"
            icon="el-icon-plus"
            size="mini"
            @click="adAdd"
            v-hasPermi="['system:dept:community']"
          >新增广告商</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="12" class="dept-statistics">
        <el-col :span="8">
          <el-card shadow="always">
            <div class="top-box-content">
              <div class="content-list">
                <count-to class="list-p1" :start-val="0" :end-val="propertyNum" :duration="2600" />
                <p class="list-p2">物业个数</p>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="always">
            <div class="top-box-content">
              <div class="content-list">
                <count-to class="list-p1" :start-val="0" :end-val="projectNum" :duration="2600" />
                <p class="list-p2">工程商个数</p>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="always">
            <div class="top-box-content">
              <div class="content-list">
                <count-to class="list-p1" :start-val="0" :end-val="communityNum" :duration="2600" />
                <p class="list-p2">小区个数</p>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
      <el-table
        v-loading="loading"
        :data="deptList"
        row-key="deptId"
        stripe
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      >
        <el-table-column prop="deptName" label="部门名称" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="orderNum" label="排序" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          :formatter="statusFormat"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <el-table-column label="部门类型" prop="type" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span>{{scope.row.type == 1 ? "工程商":scope.row.type == 2 ? "物业":scope.row.type == 3 ? "小区":scope.row.type == 4 ? "广告商":''}}</span>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createTime" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <span>{{scope.row.createTime}}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="viewPro(scope.row)"
              v-if="scope.row.unionId!=null && scope.row.unionId.length == 8"
              v-hasPermi="['system:dept:add']"
            >查看</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              v-if="scope.row.unionId==null || scope.row.unionId.length != 8"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:dept:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-circle-check"
              v-if="scope.row.parentId != 0"
              @click="handleDataScope(scope.row)"
              v-hasPermi="['system:dept:edit']"
            >区域权限</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-plus"
              v-if="scope.row.unionId==null || scope.row.unionId.length != 8"
              @click="handleAdd(scope.row)"
              v-hasPermi="['system:dept:add']"
            >新增</el-button>
            <el-button
              v-if="scope.row.parentId != 0"
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:dept:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 添加或修改部门对话框 -->
      <el-dialog :title="title" :visible.sync="open" :closeOnClickModal="false" width="600px">
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-row>
            <el-col :span="24" v-if="form.parentId !== 0">
              <el-form-item label="上级部门" prop="parentId">
                <treeselect v-model="form.parentId" :options="deptOptions" placeholder="选择上级部门" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="部门名称" prop="deptName">
                <el-input v-model.trim="form.deptName" placeholder="请输入部门名称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="显示排序" prop="orderNum">
                <el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责人" prop="leader">
                <el-input v-model.trim="form.leader" placeholder="请输入负责人" maxlength="20" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model.trim="form.phone" placeholder="请输入联系电话" maxlength="11" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="email">
                <el-input v-model.trim="form.email" placeholder="请输入邮箱" maxlength="25" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="部门状态">
                <el-radio-group v-model="form.status">
                  <el-radio
                    v-for="dict in statusOptions"
                    :key="dict.dictValue"
                    :label="dict.dictValue"
                  >{{dict.dictLabel}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 工程商 -->
      <el-dialog :title="proTitle" :visible.sync="project" :closeOnClickModal="false" width="650px">
        <el-form ref="projectForm" :model="projectForm" :rules="rules2" label-width="100px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="工程商名称" prop="deptName">
                <el-input
                  v-model.trim="projectForm.deptName"
                  :disabled="proDisabled"
                  placeholder="请输入工程商名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="显示排序" prop="orderNum">
                <el-input-number
                  v-model="projectForm.orderNum"
                  :disabled="proDisabled"
                  controls-position="right"
                  :min="0"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="负责人" prop="leader">
                <el-input
                  v-model.trim="projectForm.leader"
                  :disabled="proDisabled"
                  placeholder="请输入负责人"
                  maxlength="20"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="联系电话" prop="phone">
                <el-input
                  v-model.trim="projectForm.phone"
                  :disabled="proDisabled"
                  placeholder="请输入联系电话"
                  maxlength="11"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="user">
              <el-form-item label="账号" prop="username">
                <el-input
                  v-model.trim="projectForm.username"
                  :disabled="proDisabled"
                  placeholder="请输入账号"
                  maxlength="20"
                  autocomplete="new-password"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="user">
              <el-form-item label="密码" prop="password">
                <el-input
                  v-model.trim="projectForm.password"
                  :disabled="true"
                  type="password"
                  placeholder="请输入密码"
                  maxlength="20"
                  autocomplete="new-password"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="email">
                <el-input
                  v-model.trim="projectForm.email"
                  :disabled="proDisabled"
                  placeholder="请输入邮箱"
                  maxlength="25"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="部门状态">
                <el-radio-group v-model="projectForm.status">
                  <el-radio
                    v-for="dict in statusOptions"
                    :key="dict.dictValue"
                    :label="dict.dictValue"
                  >{{dict.dictLabel}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="keyShow">
              <el-form-item label="厂商代码" prop>
                <el-input v-model.trim="projectForm.unionId" :disabled="proDisabled" maxlength="25" />
              </el-form-item>
            </el-col>
            <el-col :span="24" v-if="keyShow">
              <el-form-item class="textContent" label="内容">
                <el-input
                  type="textarea"
                  :disabled="true"
                  :autosize="{ minRows: 7, maxRows: 7}"
                  placeholder="请输入内容"
                  v-model="textContent"
                ></el-input>
                <el-button type="primary"  v-clipboard:copy="textContent" v-clipboard:success="onCopy" v-clipboard:error="onError">复 制</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" :disabled="proDisabled" @click="submitForm2">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 修改区域权限 -->
      <el-dialog
        class="select-region"
        :title="permissTitle"
        :closeOnClickModal="false"
        width="700px"
        :visible.sync="plot"
      >
        <div class="content_wrap">
          <div class="zTreeDemoBackground left">
            <ul id="treeDemo" class="ztree"></ul>
          </div>
        </div>
        <div class="content_wrap2">
          <el-table
            v-loading="loading"
            :data="this.selectForm.permiss"
            row-key="deptId"
            stripe
            default-expand-all
          >
            <el-table-column prop="name" label="已选区域"></el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="delSelect(scope.row)"
                  v-hasPermi="['system:dept:remove']"
                >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitPermiss">确 定</el-button>
          <el-button @click="plot = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="copyright">© 版权归 {{copyright}} 所有</div>
  </div>
</template>

<script>
import "@/assets/zTree/css/metroStyle/metroStyle.css";
import {
  listDept,
  getDept,
  treeselect,
  delDept,
  addDept,
  updateDept,
  permiss,
  getPermiss,
  addProject,
  getCount
} from "@/api/system/dept";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { isName, isChartTen, isNE } from "@/utils/validate";
import CountTo from "vue-count-to";
export default {
  //刷新页面
  inject: ["reload"],
  components: { Treeselect, CountTo },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 表格树数据
      deptList: [],
      // 部门部门树选项
      deptOptions: [],
      // 弹出层标题
      title: "",
      user: true,
      keyShow: false,
      proDisabled: false,
      proTitle: "",
      permissTitle: "",
      // 是否显示弹出层
      open: false,
      project: false,
      // 状态数据字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        deptName: undefined,
        status: undefined
      },
      // my_relatedtopos:[],
      plot: false,
      // 表单参数
      form: {},
      projectForm:{},
      //区域表单参数
      selectForm: {
        deptId: "",
        permiss: []
      },

      //选中的值
      checkedList: [],
      //回显的值
      echoList: null,
      // 表单校验
      rules: {
        parentId: [
          {
            required: true,
            message: "上级部门不能为空",
            trigger: ["blur", "change"]
          }
        ],
        deptName: [
          { required: true, message: "部门名称不能为空", trigger: "blur" },
        ],
        orderNum: [
          { required: true, message: "菜单顺序不能为空", trigger: "blur" }
        ],
        leader: [
          { required: true, message: "负责人不能为空", trigger: "blur" },
          { validator: isChartTen, trigger: ["blur", "change"] },
          { validator: isName, trigger: ["blur", "change"] }
        ],
        email: [
          {
            type: "email",
            message: "'请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phone: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ],
        
      },
      rules2: {
        deptName: [
          { required: true, message: "工程商名称不能为空", trigger: "blur" },
        ],
        orderNum: [
          { required: true, message: "菜单顺序不能为空", trigger: "blur" }
        ],
        leader: [
          { required: true, message: "负责人不能为空", trigger: "blur" },
          { validator: isChartTen, trigger: ["blur", "change"] },
          { validator: isName, trigger: ["blur", "change"] }
        ],
        username: [
          { required: true, message: "账号不能为空", trigger: "blur" },
          { validator: isChartTen, trigger: ["blur", "change"] },
          { validator: isNE, trigger: ["blur", "change"] }
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: ["blur", "change"] }
        ],
        email: [
          {
            type: "email",
            message: "'请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phone: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ]
      },
      copyright: "",
      textContent:"",
      propertyNum: 0, //物业个数
      projectNum: 0, //工程商个数
      communityNum: 0 //小区个数
    };
  },
  created() {
    this.getList();
    this.getNum();
    this.getDicts("sys_normal_disable").then(response => {
      this.statusOptions = response.data;
    });
    this.copyright = sessionStorage.getItem("companyName");
  },
  methods: {
    /** 查询部门列表 */
    getList() {
      this.loading = true;
      listDept(this.queryParams).then(response => {
        this.deptList = response.data;
        this.loading = false;
      });
    },
    // 查询部门树
    getNum() {
      getCount().then(res => {
        if (res.code == 200) {
          this.propertyNum = res.data.property;
          this.projectNum = res.data.enginner;
          this.communityNum = res.data.community;
        }
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children
      };
    },
    /** 查询小区下拉树结构 */
    getTree() {
      var that = this;
      var queryParams = that.queryParams;
      // var my_relatedtopos = [];
      var checkedNodes = "";
      var setting = {
        async: {
          // 属性配置
          enable: true,
          url:
            process.env.VUE_APP_BASE_HTTP + "/blwy/region/treeDataAll?deep=3",
          autoParam: ["id", "pId", "nodeType"],
          // nodeTypeParam:{"nodeTypeParam":"zTreeAsyncTest"},
          headers: {
            Authorization: "Bearer " + getToken()
          },
          type: "post",
          dataType: "json"
        },
        checkable: true,
        showIcon: true,
        showLine: false,
        check: {
          enable: true
          // chkboxType: {"Y" : "s", "N" : "ps"}
        },
        data: {
          simpleData: {
            enable: true
          }
        },
        expandSpeed: "fast",
        callback: {
          // 回调函数配置
          onClick: function(event, treeId, treeNode) {
            var nodeType = treeNode.nodeType;
            var id = treeNode.data.id;
          },
          //复选框事件中给全局变量传值
          onCheck: function(event, treeId, treeNode) {
            var pNode2 = treeNode.getPath();
            var name = "";
            for (let i = 0, l = pNode2.length; i < l; i++) {
              name += pNode2[i].name;
            }
            if (treeNode.pId == null) {
              treeNode.pId = "0";
            }
            var arr = {
              id: treeNode.id,
              nodeType: treeNode.nodeType,
              pId: treeNode.pId,
              name: name
            };
            //判断点击的是不是最下级节点,如果是则赋值
            // if (treeNode.children == undefined) {
            //判断是选中复选框则赋值
            if (treeNode.checked == true) {
              that.selectForm.permiss.push(arr);
              // my_relatedname.push(treeNode.name);
              //判断是取消复选框则去值
            } else if (treeNode.checked == false) {
              remove_val_inarr(that.selectForm.permiss, treeNode.id);
            }
            // }
          }
        }
      };
      // 数据处理回调函数
      function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i = 0, l = childNodes.length; i < l; i++) {
          childNodes[i].name = childNodes[i].name.replace(/\.n/g, ".");
        }
        return childNodes;
      }
      // 节点点击前回调函数 (treeId -- treeId-对应zTree容器元素的id；；； treeNode -- 点击节点JSON对象)
      function beforeClick(treeId, treeNode) {
        // 选中节点
        if (!treeNode.isParent) {
          return false;
        } else {
          return true;
        }
      }
      // 异步加载前回调函数(treeId-对应zTree容器元素的id;;treeNode-进行异步加载的父节点 JSON 数据对象)
      function beforeAsync(treeId, treeNode) {
        return true;
      }
      //取消选中后删除
      function remove_val_inarr(my_relatedtopos, val) {
        for (var i = 0; i < my_relatedtopos.length; i++) {
          if (my_relatedtopos[i].id == val) {
            my_relatedtopos.splice(i, 1);
            break;
          }
        }
      }
      $(document).ready(function() {
        // 初始化树
        $.fn.zTree.init($("#treeDemo"), setting);
        // var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
        // treeObj.expandAll(true);
        // for(var i = 0; i < checkedNodes.length; i++) {
        //     // 回显选中的数据
        //     treeObj.checkNode(treeObj.getNodeByParam("id", checkedNodes[i].id), true);
        // }
      });
    },
    // 字典状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.project = false;
      // this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        deptId: undefined,
        parentId: undefined,
        deptName: undefined,
        orderNum: 1,
        leader: undefined,
        phone: undefined,
        email: undefined,
        username: undefined,
        password: undefined,
        status: "0",
      };
      this.projectForm = {
        deptId: undefined,
        parentId: undefined,
        deptName: undefined,
        orderNum: 1,
        leader: undefined,
        phone: undefined,
        email: undefined,
        username: undefined,
        password: 123456,
        status: "0",
        type:"1"
      }
      this.resetForm("form");
      this.resetForm("projectForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    //刷新操作
    handRefresh() {
      this.reload();
    },
    /** 新增按钮操作 */
    handleAdd(row) {
      this.reset();
      this.getTreeselect();
      if (row != undefined) {
        this.form.parentId = row.deptId;
      }
      this.open = true;
      this.title = "添加部门";
    },
    // 新增工程商
    projectAdd() {
      this.project = true;
      this.proTitle = "新增工程商";
      this.keyShow = false;
      this.user = true;
      this.proDisabled = false;
      this.reset();
    },
    // 新增物业
    propertyAdd(row){
      this.reset();
      this.getTreeselect();
      if (row != undefined) {
        this.form.parentId = row.deptId;
      }
      this.form.type = "2"
      this.open = true;
      this.title = "新增物业";
    },
    //新增小区
    communityAdd(row){
      this.reset();
      this.getTreeselect();
      if (row != undefined) {
        this.form.parentId = row.deptId;
      }
      this.form.type = "3"
      this.open = true;
      this.title = "新增小区";
    },
    //新增广告商
    adAdd(row){
      this.reset();
      this.getTreeselect();
      if (row != undefined) {
        this.form.parentId = row.deptId;
      }
      this.form.type = "4"
      this.open = true;
      this.title = "新增广告商";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.getTreeselect();
      getDept(row.deptId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改部门";
      });
    },
    /** 分配数据权限操作 */
    handleDataScope(row) {
      this.selectForm.permiss = [];
      this.permissTitle = "分配区域权限" + "：" + row.deptName;
      this.plot = true;
      this.selectForm.deptId = row.deptId;
      this.getTree();
      getPermiss(row.deptId).then(response => {
        if (response.code == 200 && response.data) {
          this.selectForm.permiss = response.data.permiss;
        } else {
          // that.msgError(response.msg);
          this.selectForm.permiss = [];
        }
      });
    },
    //区域权限确认
    submitPermiss() {
      if (this.selectForm.permiss == "") {
        this.$message({
          type: "warning",
          showClose: true,
          message: "请勾选需要分配的区域"
        });
      } else {
        permiss(this.selectForm).then(response => {
          if (response.code === 200) {
            this.plot = false;
            this.msgSuccess("分配成功");
          } else {
            this.msgError(response.msg);
          }
        });
      }
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.deptId != undefined) {
            delete this.form.username;
            delete this.form.password;
            updateDept(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            delete this.form.username;
            delete this.form.password;
            addDept(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },
    // 新建工程商确认操作
    submitForm2() {
      this.$refs["projectForm"].validate(valid => {
        if (valid) {
          addProject(this.projectForm).then(response => {
            if (response.code === 200) {
              this.msgSuccess("新增成功");
              this.project = false;
              this.getList();
            } else {
              this.msgError(response.msg);
            }
          });
        }
      });
    },
    //查看工程商
    viewPro(row) {
      this.textContent = ""
      getDept(row.deptId).then(response => {
        this.projectForm = response.data;
        this.keyShow = true;
        this.project = true;
        this.user = false;
        this.proDisabled = true;
        this.proTitle = "查看工程商";
        this.textContent = '平台网址：'+process.env.VUE_APP_BASE_HTTP+'\n平台账户：'+response.data.username+'\n初始密码：'+123456+'\n调试通厂商代码：'+row.unionId+'\n声明：厂商代码，只能给公司工程相关人员，是注册调试通唯一的合法认证码，可以调试设备，远程控制设备，设备报警维护管理，功能强大，慎重对待'
      });
    },
    // 复制内容
    onCopy(e) {
      this.msgSuccess('复制成功')
    },
    onError(e) {
      this.msgError('复制失败')
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm(
        '是否确认删除名称为"' + row.deptName + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(function() {
          return delDept(row.deptId);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(function() {});
    },
    //删除已选区域
    delSelect(val) {
      for (let i = 0; i < this.selectForm.permiss.length; i++) {
        if (this.selectForm.permiss[i].id == val.id) {
          this.selectForm.permiss.splice(i, 1);
        }
      }
    }
  }
};
</script>
<style lang="scss" scoped>
/deep/
.el-input.is-disabled .el-input__inner{
  color: #606266;
}
/deep/
.el-textarea.is-disabled .el-textarea__inner{
  color: #606266;
}
/deep/
.el-form-item__label{
  white-space: nowrap;
}
</style>